<style>
#adminTable input,#adminTable div,#adminTable textarea {
	width: 100%;
	margin: 0;
	padding: 0;
	left: 0;
}

#adminTable {
	border-collapse: collapse;
	margin: 5px 5px 5px 15px;
}

#adminTable td {
	vertical-align: top;
	border: 1px solid #888;
}
</style>
<script type="text/javascript">
$(function(){
      $('.wysiwyg').each(function(){$(this).wysiwyg()});
});
</script>
<link rel="stylesheet"
	href="<?php echo Yii::app()->request->baseUrl;?>/jwysiwyg/jquery.wysiwyg.css"
	type="text/css" />
<script
	type="text/javascript"
	src="<?php echo Yii::app()->request->baseUrl;?>/jwysiwyg/jquery.wysiwyg.js"></script>
<div data-role="page">
	<div data-role="header" data-theme="b">
		<h1>
		帖子管理
		</h1>
		<?php echo CHtml::link("管理员首页",array("admin/index"),array("data-icon"=>"home"))?>
		<?php echo CHtml::link("注销",array("site/logout"),array("rel"=>"external"));?>
	</div>
	
	
	<div class="content-primary">
	<div style="text-align: center; border-bottom: 0px solid #888; margin: 20px; padding-bottom: 20px;">
		<?php echo CHtml::form(array('postadmin'),'get',array("data-ajax"=>"false")); ?>
		<p>输入要查看的帖子ID然后点‘搜索’</p>
		<?php if (!empty($error)):?>
		<p><span style="color: red;">Error:<?php echo $error;?></span></p>
		<?php endif?>
		<?php if (!empty($info)):?>
		<p><span style="color: green;">info:<?php echo $info;?></span></p>
		<?php endif?>	
		<input type="text" name="id"
			value="<?php echo !empty($id)?$id:""?>"/><input
			type='submit' data-icon='search' value='搜索' data-inline=true />
		<?php echo CHtml::endForm(); ?>
	</div>
	
	<?php if (!empty($topic)&&!empty($posts)):?>
	<?php echo CHtml::form(array('postadmin'),'get',array("data-ajax"=>"false")); ?>
	<input type="hidden" name="id"
			value="<?php echo $topic->id;?>" />
	<input type="hidden" name="NewsTopic[id]"
			value="<?php echo $topic->id;?>" />		
	<table id="adminTable">
		<tr><td colspan=7>主题编辑</td></tr>
		<tr>
			<td width="20px"></td>
			<td width="40px">版块ID</td>
			<td>版块名称</td>
			<td>帖子名称</td>
			<td>帖子作者</td>
			<td>帖子状态</td>
			<td>置顶</td>	
		</tr>
		<tr>
			<td></td>
			<td><?php echo CHtml::activeTextField($topic,"category_id");?></td>
			<td><?php echo $topic->category;?></td>
			<td><?php echo CHtml::activeTextField($topic,"title");?></td>
			<td><?php echo $topic->author;?></td>
			<td><?php echo $topic->flag?></td>
			<td><?php echo CHtml::activeCheckBox($topic,"featured",array("checked"=>$topic->flag=="featured"?"checked":"")); ?>
			</td>
		</tr>
	</table>
	<div data-role="controlgroup" data-type="horizontal" style="margin-left:15px;">
			
			<?php echo CHtml::submitButton('和谐此贴',array("name"=>"delete","data-icon"=>"delete")); ?>
			<?php echo CHtml::submitButton('主题修改',array("name"=>"edit","data-icon"=>"check")); ?>
	</div>
	<?php echo CHtml::endForm(); ?>
	
	<?php echo CHtml::form(array('postsave'),'post',array("data-ajax"=>"false")); ?>
	<input type="hidden" name="id"
			value="<?php echo $topic->id;?>" />		
		<table id="adminTable">
			<tr><td colspan=7>全楼编辑</td></tr>
			<tr>
				<td width="20px">隐藏</td>
				<td width="40px">楼</td>
				<td width="150px">标题</td>
				<td width="600px">内容</td>
				<td width="80px">作者ID</td>
				<td width="80px">作者</td>
				<td width="150px">时间</td>
			</tr>
			<?php $thisPage = $pages->currentPage;?>
			<?php $n= $thisPage*20;?>
			<?php foreach($posts as $index => $post):?>
			<?php echo CHtml::activeHiddenField($post,"[$index]id"); ?>
			<?php echo CHtml::activeHiddenField($post,"[$index]topic_id"); ?>
			<?php echo CHtml::activeHiddenField($post,"[$index]member_id"); ?>
			<?php echo CHtml::activeHiddenField($post,"[$index]author"); ?>
			<?php echo CHtml::activeHiddenField($post,"[$index]created"); ?>
			<?php $n++;?>
			<tr>
				<td><?php echo CHtml::activeCheckBox($post,"[$index]hide",array("checked"=>$post->flag=="inactive"?"checked":"")); ?>
				</td>
				<td><?php echo $n?>楼</td>
				<td><?php echo CHtml::activeTextField($post,"[$index]title"); ?>
				</td>
				<td><?php echo CHtml::activeTextArea($post,"[$index]content",array("style"=>"height:140px;width:600px;;",'class'=>'wysiwyg')); ?>
			</td>
				<td><?php echo $post->member_id; ?>
				</td>
				<td><?php echo $post->author; ?>
				</td>
				<td><?php echo $post->created; ?>
				</td>
			</tr>
			<?php endforeach?>
		</table>
	
		<div data-role="controlgroup" data-type="horizontal"style="margin-left:15px;">
			<?php echo CHtml::submitButton('全贴编辑',array("name"=>"save","data-icon"=>"check")); ?>
		</div>
	<?php echo CHtml::endForm(); ?>
	<?php $this->widget('CLinkPager',array(
							'header'=>"",
							'htmlOptions'=>array("id"=>"pagerDiv"),
							'pages'=>$pages, 
							"cssFile" => "", 
							"maxButtonCount"=>0,
							"firstPageLabel"=>"<span data-role='button' data-inline='true' data-icon='home'>初页</span>",
							"lastPageLabel"=>"",
							"prevPageLabel"=>"<span data-role='button' data-inline='true'  data-icon='arrow-l'>上页</span>",
							"nextPageLabel"=>"<span data-role='button' data-inline='true' data-icon='arrow-r'>下页</span>")
	)?>	
	<?php endif?>
	
	
	
	
	
	
	
	
			
	</div>
	<!--/content-primary -->

	<div data-role="footer" data-theme="b">
		<h5>&copy; iweb.sg 后台管理</h5>
	</div>
	<!-- /footer -->
</div>
<!-- /page -->